package com.kathryn.LG;


import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.Toast;

import com.demo.R;

public class MainActivity extends Activity {
	private ListView listview;
	private List<GalleryItem> galleryitem = new ArrayList<GalleryItem>();
	private ArrayList<MyList> serialList = new ArrayList<MyList>();
	
	private int[] imageIds = {R.drawable.image1,R.drawable.image2,R.drawable.image3,R.drawable.image4,R.drawable.image5,R.drawable.image6};
	private String[] serialNames = {"Listview1","Listview2","Listview3","Listview4","Listview5","Listview"};
	
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        listview = (ListView) findViewById(R.id.listview);
        
        for (int i = 0; i < 6; i++) {
        	MyList serial = new MyList();
        	serial.setSerialName(serialNames[i]);
        	serial.setImageurl(imageIds);
        	serialList.add(serial);
		}
        
        SpecialAdapter	mAdapter = new SpecialAdapter(this, galleryitem, serialList,
				new int[] { R.id.serialName });
		listview.setAdapter(mAdapter);
		
        initItems();
        
    }
    private void initItems() {
		// 初始化ListItem项
		GalleryItem item = null;
		for (int i = 0; i < serialList.size(); i++) {
			item = new GalleryItem(this);
			item.serialList=serialList;
			item.initAdapter(this);
			galleryitem.add(item);
		}
	}
    private void setlistview() {
		
		listview.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				Toast.makeText(getApplicationContext(), " listview position"+arg2, 0).show();
				
			}
			
		});
	}
    
}